<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>表单验证</title>
		<script>
		 function checkForm(f){
			 //var like=document.getElementsByName("like");
			 var l=f.like;//document.forms[0].like
			 var count=0;
			 for(var i=0;i<l.length;i++){
				 if(l[i].checked){
					 count++;
				 }
			 }
			 if(count<2){
				 alert("至少要选两个");
				 
				 return false;
			 }
			 return true;
		 }
		</script>
	</head>
	<body>
		<h1>云豆网注册</h1>
		<form action="reg.html" method="get" onsubmit="return checkForm(this)">
			<fieldset >登录名
				<input type="text" name="loginname" placeholder="登录名" required pattern="\w{2,30}"/>
			</fieldset> 
			<fieldset>密码
			<input type="password" name="pass" placeholder="密码" required pattern="\S{6,30}"/>
			</fieldset>
			<fieldset>
				爱好（至少选择两个）:
				<input type="checkbox" name="like" value="sing"/>唱歌
				<input type="checkbox" name="like" value="dance"/>跳舞
				<input type="checkbox" name="like" value="Rap"/>说唱
				<input type="checkbox" name="like" value="baseketball"/>篮球
				<input type="checkbox" name="like" value="Study"/>学习
				<span id="LikeTip"></span>
			</fieldset>
			<fieldset>
				请勾选同意我们的<a href="#">用户协议</a><input type="checkbox" name="accpet" required/>
			</fieldset>
			<p>
				<input type="submit" value="注册"/>
			</p>
		</form>
	</body>
</html>
